<template>
  <div>
    <div style="margin: 40px 20px 20px 20px;">
         <div style="width: 50%;">
            <el-form ref="form" :model="psw" label-width="90px">
                <el-form-item label="原密码" :required="true">
                  <el-input v-model="psw.oldpassword" placeholder="请输入旧密码"></el-input>
                </el-form-item>
                <el-form-item label="新密码" :required="true">
                  <el-input v-model="psw.newpassword" placeholder="请输入新密码"></el-input>
                </el-form-item>
                <el-form-item label="再次输入" :required="true">
                  <el-input v-model="psw.repass" placeholder="请再次输入新密码"></el-input>
                </el-form-item>
              </el-form>
              <div style="text-indent: 25%;">
              <el-button type="success" @click="submitPsw(psw)">提交修改</el-button>
              </div>
            </div>
         </div>
    </div>
  </div>
</template>

<script>
  export default{
    data(){
      return{
        psw:{
           oldpassword:'',
                    newpassword:'',
                    repass:''
        }

      }
    },
    methods:{
      //提交修改密码
      submitPsw(psw){
        const loadingOne = this.$loading({
          lock: true,
          text: '保存中...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
          this.$api.changePassword(psw).then(res=>{
            console.log(res)
            if(res.data.level == "success"){
                this.$message.success(res.data.message)
                loadingOne.close()
                this.modelPsw = false
            }else{
              this.$message.error(res.data.message)
               loadingOne.close()
            }
          })
           loadingOne.close()
      },
    }
  }
</script>

<style scoped="scoped">
    .el-input{
     width: 60%;
    }
    .el-form-item{
      margin-bottom: 40px;
    }
    /deep/label{
      font-size: 16px;
      font-weight: 500 !important;
    }
</style>
